/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.myapp.dbdao;

import com.myapp.bo.Eventor;
import com.myapp.bo.WantEsBO;
import com.myapp.util.DBConfig;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author toint - LifeTek
 * @since 12/2013
 * @version 1.0
 */
public class WantEsDBDAO {
    public static List<WantEsBO> lstWants(int status) throws SQLException {
        String sql = "select want_id, code, name, parent_id from estimate_want where status = ?";
        Connection conn = DBConfig.getConnection();
        List<WantEsBO> lstResult = new ArrayList<WantEsBO>();
        CallableStatement stm = conn.prepareCall(sql);
        WantEsBO item;
        stm.setInt(1, status);
        ResultSet rs = stm.executeQuery();
        while (rs.next()) {
            item = new WantEsBO();
            item.setWantId(rs.getInt("want_id"));
            item.setCode(rs.getString("code"));
            item.setName(rs.getString("name"));
            item.setParentId(rs.getInt("parent_id"));
            lstResult.add(item);
        }
        return lstResult;
    }
}
